//全局Loading组件
import { ElLoading } from 'element-plus'
export default function useGlobalLoading() {
    let loading:any;
    let loadingCount = 0;
    //开启loading
    const addOnceLoading = () => {
        loadingCount++
        loading = ElLoading.service({
            lock: true,
            text: '加载中',
            background: 'rgba(0, 0, 0, 0.1)',
          })
    }
    //减一个loading
    const cutOnceLoading = () => {
        loadingCount--
       if (loadingCount===0) {
        loading.close()
       }
    }
    //返回需要暴露的数据和函数
    return {
        addOnceLoading,
        cutOnceLoading,
    }
}
